﻿
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

//{{{ file documentation -------------------------------------------------------

/*!
 * @file     mainwindow.h
 * @brief    dicodor mainwindow class declaration
 */

//}}} --------------------------------------------------------------------------
//{{{ includes / predeclarations -----------------------------------------------

// @(#) $Id: mainwindow.h 50 2012-05-21 12:47:32Z nsouchon-dico@altern.org $

#include "ortho.h"
#include "config.h"
#include "preferences.h"
#include "textedit.h"

#include <QtGui/QMainWindow>
#include <QtGui/QTextDocument>
#include <QtGui/QTextEdit>

//}}} --------------------------------------------------------------------------
//{{{ namespace Ui -------------------------------------------------------------

namespace               Ui
{
    class               MainWindow;
}

//}}} --------------------------------------------------------------------------
//{{{ structures ---------------------------------------------------------------
//}}} --------------------------------------------------------------------------
//{{{ .MainWindow --------------------------------------------------------------

class MainWindow :      public QMainWindow
{
    Q_OBJECT;

public:
    explicit            MainWindow (const QString & documentPath, QWidget * parent = 0);
    virtual             ~MainWindow ();

private:
    void                initTests ();
    void                initWindow ();
    void                initMenu ();
    void                initToolbar ();
    void                initConnect ();
    void                initDocument ();

    QString             selectedUnknownWord ();

    void                open (const QString& path);

protected:
    void                changeEvent (QEvent * e);

private slots:
    void                on_ignore_clicked ();
    void                on_addToPersonalDic_clicked ();
    void                on_replaceAlways_clicked ();
    void                on_replaceAll_clicked ();
    void                on_removeWordFromText_clicked ();
    void                on_actionAboutQt_triggered ();
    void                on_actionPreferences_triggered ();
    void                on_actionOpen_triggered ();
    void                on_actionShowMessages_triggered ();
    void                on_edit_textChanged ();

    void                onUnknownListCurrentTextChanged (const QString & word);
    void                onMessage (const QString & msg);

private:
    Ui::MainWindow    * ui;
    Ortho             * m_ortho;
    Config            * m_config;
    QToolBar          * m_toolBar;
    QString             m_documentPath;
    QTextDocument     * m_doc;
    TextEdit          * m_edit;
    QStringList         m_messages;
};

//}}} --------------------------------------------------------------------------

#endif // MAINWINDOW_H

